
import edu.uci.ics.jung.algorithms.layout.ISOMLayout;
import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.SparseMultigraph;
import edu.uci.ics.jung.graph.util.EdgeType;
import edu.uci.ics.jung.graph.util.Pair;
import edu.uci.ics.jung.visualization.BasicVisualizationServer;
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller;
import edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position;
import org.apache.commons.collections15.Transformer;

import javax.swing.*;
import java.awt.*;
import java.util.Collection;


class Main implements Graph
{
	public static void main(String []args)
	{
		// Graph<V, E> where V is the type of the vertices
		// and E is the type of the edges
	 MyNode n1,n2,n4,n5,n3;
	 System.out.println(new MyLink(2.0));
	 Graph<Integer, MyLink> g = new SparseMultigraph<Integer, MyLink>();
	 // Add some vertices. From above we defined these to be type Integer.
	 g.addVertex((Integer)1);
	 g.addVertex((Integer)2);
	 g.addVertex((Integer)3);
	 g.addVertex((Integer)4);
	 g.addVertex((Integer)5);
	 g.addVertex((Integer)6);
	 g.addVertex((Integer)7);
	 // Add some edges. From above we defined these to be of type String
	 // Note that the default is for undirected edges.
	 g.addEdge(new MyLink(2.0), 1, 2); // Note that Java 1.5 auto-boxes primitives
	 g.addEdge(new MyLink(2.0), 2, 3);
	 g.addEdge(new MyLink(2.0), 1, 4);
	 g.addEdge(new MyLink(2.0), 6, 1);
     g.addEdge(new MyLink(2.0), 2, 6);
     g.addEdge(new MyLink(2.0), 7, 6);
     g.addEdge(new MyLink(2.0), 5, 7);
 	// g.addEdge("asdsdasda",2,4);	
	 // Let's see what we have. Note the nice output from the
	 // SparseMultigraph<V,E> toString() method
	 System.out.println("The graph g = " + g.toString());
	 // Note that we can use the same nodes and edges in two different graphs.
		// Graph<V, E> where V is the type of the vertices
		Main sgv = new Main(); //We create our graph in here
		
		Layout<Integer, MyLink> layout = new ISOMLayout<Integer, MyLink>(g);
		
		layout.setSize(new Dimension(1000,500));
		BasicVisualizationServer<Integer,MyLink> vv =
		new BasicVisualizationServer<Integer,MyLink>(layout);
		vv.setPreferredSize(new Dimension(350,350));
		// Setup up a new vertex to paint transformer...
		Transformer<Integer,Paint> vertexPaint = new Transformer<Integer,Paint>() {
		public Paint transform(Integer x) {
		
	      if(x==1)return Color.GREEN;
	      else return Color.RED;
		}
		};
		// Set up a new stroke Transformer for the edges
		float dash[] = {10000.0f};
		float dash2[] = {1000.0f};
		final Stroke edgeStroke1 = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
		BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
		final Stroke edgeStroke2 = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
				BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
		Transformer<MyLink, Stroke> edgeStrokeTransformer =
		new Transformer<MyLink, Stroke>() {
		public Stroke transform(MyLink s) {
				return edgeStroke1;
		
		}
		};
		vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
		vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
		vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
		vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
		vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
		JFrame frame = new JFrame("Simple Graph View 2");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().add(vv);
		frame.pack();
		frame.setSize(new Dimension(1000,500));
		frame.setVisible(true);
		}


	public boolean addEdge(Object arg0, Collection arg1) {
		// TODO Auto-generated method stub
		return false;
	}


	public boolean addEdge(Object arg0, Collection arg1, EdgeType arg2) {
		// TODO Auto-generated method stub
		return false;
	}


	public boolean addVertex(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}


	public boolean containsEdge(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}


	public boolean containsVertex(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}


	public int degree(Object arg0) {
		// TODO Auto-generated method stub
		return 0;
	}


	public Object findEdge(Object arg0, Object arg1) {
		// TODO Auto-generated method stub
		return null;
	}


	public Collection findEdgeSet(Object arg0, Object arg1) {
		// TODO Auto-generated method stub
		return null;
	}


	public EdgeType getDefaultEdgeType() {
		// TODO Auto-generated method stub
		return null;
	}


	public int getEdgeCount() {
		// TODO Auto-generated method stub
		return 0;
	}


	public int getEdgeCount(EdgeType arg0) {
		// TODO Auto-generated method stub
		return 0;
	}


	public EdgeType getEdgeType(Object arg0) {
		// TODO Auto-generated method stub
		return null;
	}


	public Collection getEdges() {
		// TODO Auto-generated method stub
		return null;
	}


	public Collection getEdges(EdgeType arg0) {
		// TODO Auto-generated method stub
		return null;
	}


	public int getIncidentCount(Object arg0) {
		// TODO Auto-generated method stub
		return 0;
	}


	public Collection getIncidentEdges(Object arg0) {
		// TODO Auto-generated method stub
		return null;
	}


	public Collection getIncidentVertices(Object arg0) {
		// TODO Auto-generated method stub
		return null;
	}


	public int getNeighborCount(Object arg0) {
		// TODO Auto-generated method stub
		return 0;
	}


	public Collection getNeighbors(Object arg0) {
		// TODO Auto-generated method stub
		return null;
	}


	public int getVertexCount() {
		// TODO Auto-generated method stub
		return 0;
	}


	public Collection getVertices() {
		// TODO Auto-generated method stub
		return null;
	}


	public boolean isIncident(Object arg0, Object arg1) {
		// TODO Auto-generated method stub
		return false;
	}


	public boolean isNeighbor(Object arg0, Object arg1) {
		// TODO Auto-generated method stub
		return false;
	}


	public boolean removeEdge(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}


	public boolean removeVertex(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}


	public boolean addEdge(Object arg0, Object arg1, Object arg2) {
		// TODO Auto-generated method stub
		return false;
	}


	public boolean addEdge(Object arg0, Object arg1, Object arg2, EdgeType arg3) {
		// TODO Auto-generated method stub
		return false;
	}


	public Object getDest(Object arg0) {
		// TODO Auto-generated method stub
		return null;
	}


	public Pair getEndpoints(Object arg0) {
		// TODO Auto-generated method stub
		return null;
	}


	public Collection getInEdges(Object arg0) {
		// TODO Auto-generated method stub
		return null;
	}


	public Object getOpposite(Object arg0, Object arg1) {
		// TODO Auto-generated method stub
		return null;
	}


	public Collection getOutEdges(Object arg0) {
		// TODO Auto-generated method stub
		return null;
	}


	public int getPredecessorCount(Object arg0) {
		// TODO Auto-generated method stub
		return 0;
	}


	public Collection getPredecessors(Object arg0) {
		// TODO Auto-generated method stub
		return null;
	}


	public Object getSource(Object arg0) {
		// TODO Auto-generated method stub
		return null;
	}


	public int getSuccessorCount(Object arg0) {
		// TODO Auto-generated method stub
		return 0;
	}


	public Collection getSuccessors(Object arg0) {
		// TODO Auto-generated method stub
		return null;
	}


	public int inDegree(Object arg0) {
		// TODO Auto-generated method stub
		return 0;
	}


	public boolean isDest(Object arg0, Object arg1) {
		// TODO Auto-generated method stub
		return false;
	}


	public boolean isPredecessor(Object arg0, Object arg1) {
		// TODO Auto-generated method stub
		return false;
	}


	public boolean isSource(Object arg0, Object arg1) {
		// TODO Auto-generated method stub
		return false;
	}


	public boolean isSuccessor(Object arg0, Object arg1) {
		// TODO Auto-generated method stub
		return false;
	}


	public int outDegree(Object arg0) {
		// TODO Auto-generated method stub
		return 0;
	}
}
